//
//  FirstCrameViewController.m
//  旅游咨询
//
//  Created by 高建 on 15/4/23.
//  Copyright (c) 2015年 xubin. All rights reserved.
//

#import "FirstCrameViewController.h"

@interface FirstCrameViewController ()

@end

@implementation FirstCrameViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor greenColor];
    
    [self.navigationController setNavigationBarHidden:YES];
    
    UICollectionViewFlowLayout *flowLayOut = [[UICollectionViewFlowLayout alloc] init];
    flowLayOut.itemSize = CGSizeMake(WidthZ, HeighZ);
    flowLayOut.sectionInset = UIEdgeInsetsMake(0, 0, 0, 0);
    flowLayOut.scrollDirection = UICollectionViewScrollDirectionHorizontal;
//    flowLayOut.minimumInteritemSpacing = 3;
    flowLayOut.headerReferenceSize = CGSizeMake(0, 0);
    flowLayOut.minimumInteritemSpacing = 0;
    flowLayOut.minimumLineSpacing = 0;
    //集合视图
    UICollectionView *myCollectionView = [[UICollectionView alloc] initWithFrame:[[UIScreen mainScreen] bounds] collectionViewLayout:flowLayOut];
    [self.view addSubview:myCollectionView];
    myCollectionView.backgroundColor = [UIColor blackColor];
    myCollectionView.delegate = self;
    myCollectionView.dataSource = self;
    [myCollectionView release];
    myCollectionView.pagingEnabled = YES;
    //注册cell
    [myCollectionView registerClass:[FirstCrameCollectionViewCell class] forCellWithReuseIdentifier:@"reuse"];
//    NSLog(@"woshizhaopianshuzu%@", self.FirstCramePhotoArray);

    UIButton *myButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [myButton addTarget:self action:@selector(myButtonAction) forControlEvents:UIControlEventTouchUpInside];
    [myButton setBackgroundImage:[UIImage imageNamed:@"add_new_poi_back_btn.png"] forState:UIControlStateNormal];
    myButton.frame = CGRectMake(0, 0, 30, 30);
    self.myView = [[UIView alloc]initWithFrame:CGRectMake(10, 30, 30, 30)];
    [self.myView addSubview:myButton];
    [self.view addSubview:self.myView];
    
    myCollectionView.contentOffset = CGPointMake(WidthZ *self.index, 0);
    [self.view bringSubviewToFront:self.myView];
    
}

- (void)myButtonAction
{
    [self.navigationController popViewControllerAnimated:YES];
}

//显示item上的内容
-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
    FirstCrameCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"reuse" forIndexPath:indexPath];
    cell.backgroundColor = [UIColor blackColor];
    
    //改变边框形状
//    cell.PhotoImageView.layer.masksToBounds = YES;
//    cell.PhotoImageView.layer.cornerRadius = 3;
    cell.myFirstCrame = [self.FirstCramePhotoArray objectAtIndex:indexPath.row];
    //    NSLog(@"++++++++++++++++_+++++++++%@",myPhotoModel);
//
//    cell.firstPhoto = myPhotoModel;
    
    
    
    return cell;
}
-(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
    
}

//- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath
//{
//  
//    NSString *w = [[[self.FirstCramePhotoArray objectAtIndex:indexPath.row] photo_info] objectForKey:@"w"];
//    NSString *h = [[[self.FirstCramePhotoArray objectAtIndex:indexPath.row] photo_info] objectForKey:@"h"];
//    
//    CGSize photoSize = CGSizeMake(WidthZ * 0.9733, [h floatValue] * (WidthZ * 0.9733) / [w floatValue])
//    ;
//    return photoSize;
//    
//    
//}

-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
    return self.FirstCramePhotoArray.count;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
